<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('贷款记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								借款人：<input type="text" name="loanBorrower"/>
							</li>

							<li>
								借款金额：<input type="text" name="loanAmounts"/>
							</li>

							<li>
								借款渠道：<input type="text" name="loanPlace"/>
							</li>

							<li>
								借多久：<input type="text" name="loanHowLong"/>
							</li>

							<li>
								还款方式：<input type="text" name="paymentMethod"/>
							</li>


							<li>
								借款用途：<input type="text" name="loanUse"/>
							</li>


							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="loans:loansLog:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="loans:loansLog:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="loans:loansLog:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="loans:loansLog:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('loans:loansLog:edit')}]];
        var removeFlag = [[${@permission.hasPermi('loans:loansLog:remove')}]];
		// 贷款渠道
		var loans_place_datas = [[${@dict.getType('loans_place')}]];
		// 贷款用途
		var loans_use_datas = [[${@dict.getType('loans_use')}]];
		// 	还款方式
		var payment_methods_datas = [[${@dict.getType('payment_methods')}]];
        var prefix = ctx + "loans/loansLog";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "贷款记录",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : '',
					visible: false
				},
				{
					field : 'loanBorrower', 
					title : '借款人',
				},
				{
					field : 'loanAmounts', 
					title : '借款金额',
					sortable: true
				},
				{
					field : 'loanPlace', 
					title : '借款渠道',
					align: 'center',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(loans_place_datas, value);
					}
				},
				{
					field : 'loanHowLong', 
					title : '借多久',
					sortable: true
				},
				{
					field : 'loanTime',
					title : '借款时间',
					sortable: true
				},
				{
					field : 'loanRate',
					title : '借款利率',
				},
				{
					field : 'paymentMethod', 
					title : '还款方式',
					align: 'center',
					formatter: function(value, row, index) {
						return '<a href="javascript:void(0)" onclick="paymentDetail(\'' + row.id + '\')">' + $.table.selectDictLabel(payment_methods_datas, value) + '</a>';
					}
				},
				{
					field : 'loanUse', 
					title : '借款用途',
					align: 'center',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(loans_use_datas, value);
					}
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });

        function paymentDetail(id){
			$.modal.open("还款计划",  "/loans/paymentDetail/"+id);
		}
    </script>
</body>
</html>